#version 330

layout(location = 0) in vec3 VertexPosition;
layout(location = 2) in vec3 VertexNormal;
layout(location = 4) in vec2 VertexTextureCoord;

uniform mat4 osg_ModelViewProjectionMatrix;
uniform mat4 osg_ViewMatrixInverse;
uniform mat4 osg_ModelViewMatrix;
uniform mat4 ProjectionMatrix;
uniform mat4 ViewMatrix;

out vec3 posInScene;
out vec3 normalInScene;
out vec2 TexCoord1;

void main()
{
	//gl_Position = osg_ModelViewProjectionMatrix * vec4(VertexPosition,1);
	mat4 modelMatrix = osg_ViewMatrixInverse * osg_ModelViewMatrix;
	gl_Position = ProjectionMatrix * ViewMatrix * modelMatrix * vec4(VertexPosition, 1);
	posInScene = (modelMatrix * vec4(VertexPosition,1)).xyz;

	normalInScene = mat3(modelMatrix)*VertexNormal;
	normalInScene = (normalInScene + vec3(1)) / 2;

	TexCoord1 = VertexTextureCoord;


}